package ay.shadow.core.exception;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.util.StringUtils;

import java.io.Serial;

/**
 * @author shdaow
 */
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class ShadowException extends RuntimeException {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 所属模块
     */
    private String moduleName;

    /**
     * 错误码
     */
    private String code;

    /**
     * 错误码对应的参数
     */
    private Object[] args;

    /**
     * 错误消息
     */
    private String message;

    public ShadowException(String moduleName, String code, Object[] args) {
        this(moduleName, code, args, null);
    }

    public ShadowException(String moduleName, String message) {
        this(moduleName, null, null, message);
    }

    public ShadowException(String code, Object[] args) {
        this(null, code, args, null);
    }

    public ShadowException(String message) {
        this(null, null, null, message);
    }
}
